-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(systemd/smartdns.service.in): securing systemd service #1995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
这些选项是否会导致ipv6 ping或nftables的ipset不可用? |
不会,已经测试过了。 ip 测速功能正常 ipset、nftset 都可以正常添加 选项相关配置文件 查询后,可以看到相关IP已被添加至 nft set、ipset # nft list set ip smartdns public_set
table ip smartdns {
set public_set {
type ipv4_addr
flags interval
auto-merge
elements = { 23.215.0.136, 23.215.0.138 }
}
}
# ipset list smartdns
Name: smartdns
Type: hash:net
Revision: 7
Header: family inet hashsize 1024 maxelem 65536 bucketsize 12 initval 0xe8b8173d
Size in memory: 552
References: 0
Number of entries: 2
Members:
23.215.0.136
23.215.0.138 |
|
简单解释一下,那一大堆加固选项的含义吧。
参考资料: |
|
systemd 中与网络服务关系比较大的 ipset、nftset 已经通过 |
|
可能影响比较大的选项是 |
|
个人觉得保持和其他程序默认一致就可以了,上面列的大部分限制,smartdns都没有相关的代码。 |
程序应当默认安全,尽可能最小权限,smartdns没有相关的功能,这不正意味着应用这些限制不会对程序产生影响。
使用非特权用户运行服务,这个PR就是这个目的。不过使用 nobody 已经是不推荐的做法,会被其它使用 nobody 运行的程序影响,这里使用 DynamicUser,运行服务时动态创建一个临时用户。
|
|
安装后,几乎没有人去修改smartdns.service文件。 默认的代码已经设置drop root权限的。 你那个修改设置的capbility还缺少NET_RAW权限,没这个icmp ping在某些系统上可能无法工作。 所以对于这些修改,特别是目录只读权限的修改,这个影响目前未知。 安全和易用性就是双刃剑,找到适合的点即可,没必要过度设置。 最后,还是感谢你的测试和验证。 |
858ab9e to
b547030
Compare
对 smartdns.service 进行加固,具体内容如下:
使用非特权用户运行服务
因为有了
RuntimeDirectory,这里不再需要@RUNSTATEDIR@因为 /etc/smartdns/smartdns.conf 默认为 root 0640 权限,使用 LoadCredential 使非特权用户可以读取配置文件。
授予运行服务所需特权:
ipset、nftset选项所必须一大堆加固选项,具体说明可以读 systemd 文档